<?php
function renren_get_friends() {
  require_once ('renren.config.inc'); //$config
  require_once ('renren.common.inc');

  $client = new RenRenClient();
  $friends = array();

  /*if ($session_key = $_SESSION['session_renren']['renren_token']['session_key']) {
    $client->setSessionKey($session_key);
    $friends = $client->POST('friends.getFriends', array('1', '100'));
  } else {
    echo t('Need Sign in');
  }*/

  return $friends;
}

/**
 * 分享的类型：日志为1、照片为2、链接为6、相册为8、视频为10、音频为11、分享为20。
 */
function renren_share_link($url, $type = 6) {
  //$url ='http://naturemana.com/content/2011/12/22/208.html';
  if ($session_key = $_SESSION['renren_session']['session_key']) {
    require ('renren.config.inc');
    require_once ('renren.common.inc');
    $uid = $_SESSION['renren_session']['uid'];
    $client = new RenRenClient($config);
    $client->setSessionKey($session_key);
    //type,url,ugc_id,user_id,comment
    //$share = $client->POST('friends.getFriends', array('1', '20'));//
    $share = $client->POST('share.share', array($type, $url, NULL, $uid, NULL));
    if ($share['error_code']) {
      //$share['error_msg'];//TODO LOG
    }
  } else {
    echo 'need login';
  }

}